<%-- 
    Document   : queryInfo
    Created on : 2017-3-24, 10:15:04
    Author     : 52461
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="../../link.jsp"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>质控靶值管理</title>
        <style>
            .form-control{
                width: 100px;
            }
        </style>
    </head>
    <body ng-app="zkValueApp" ng-controller="mainCtrl" style="overflow: hidden;margin-top: 5px;">
        <div class="container">
            <div class="col-lg-12">
                <div class="panel panel-default" style="overflow: hidden">

                    <div class="panel-heading head-width"><span style="float: left;line-height: 30px;font-size: 16px; font-weight: bold;margin-right: 10px;">质控靶值管理</span>
                        <div class="form-inline">

                            <div class="form-group">
                                <label for="startTime">设备:</label>
                                <select ng-model="device" ng-change="getPh()" style="width:120px" class="form-control" id="startTime">
                                    <option ng-repeat="de in des" value="{{de.DEVICEMODEL}}">{{de.DEVICEMODEL}}</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="startTime">试剂批号:</label>
                                <select ng-model="ph" ng-init="ph = phs[0]"  ng-change="queryDeviceStandard()" ng-options="x.BATCH_NUMBER for x in phs" style="width:120px" class="form-control" >

                                </select>
                            </div>
                            <button ng-disabled="!items" ng-click="saveDeviceStandard()" class="btn btn-success "><span class="fa fa-save"></span>&nbsp;&nbsp;&nbsp;保存</button>
                            <!--<button ng-click="printResult()" class="btn btn-success btn-sm"><span class="fa fa-print"></span>&nbsp;&nbsp;&nbsp;打印</button>-->
                        </div>


                        <div style="clear: both"></div>
                    </div>  
                    <table  style="width:100%">


                        <tr>
                            <td  class="main-left" valign="top" style="overflow: auto">
                                <div class=" main main-left" style="overflow: auto;width: 100%"  >
                                    <table class="table table-bordered ">
                                        <tr>
                                            <th style="width:50px;">序号</th>
                                            <th>缩写</th>

                                            <th>靶值</th>
                                            <th>SD（标准差）</th>                                      
                                            <th>Cv(%)</th>
                                        </tr>
                                        <tr ng-repeat="list in items" >
                                            <td style="width:50px;" ng-bind="$index" ></td>
                                            <td ng-bind="list.TESTID"></td>
                                            <td contenteditable="true" ng-model="list.STANDARD_VALUE"></td>
                                            <td contenteditable="true" ng-model="list.SD" ></td>
                                            <td contenteditable="true" ng-model="list.CV"></td>

                                        </tr>
                                    </table>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>

                </div>

            </div>
        </div>
    </body>
</html>
<script>
    angular.module("zkValueApp", ['baseModule', 'ui.bootstrap'])

            .controller("mainCtrl", function ($scope, base) {

                $scope.getDeviceType = function () {
                    base.post("${base}/view/host/getType").get(function (data) {
                        $scope.des = data;
                    });
                };
                $scope.getPh = function () {
                    
                    base.post("zk_value/getPh", {device: $scope.device}).get(function (data) {
                        $scope.phs = data;
                        $scope.ph = data[0];
                         $scope.queryDeviceStandard();
                    })
                };
                $scope.queryDeviceStandard = function () {
                     $scope.items=[];
                    base.post("zk_value/getDeviceStandard", {device: $scope.device, zk_reagent_pk: $scope.ph.PK}).get(function (data) {
                        
                        $scope.items = data;
                    });
                };
                $scope.saveDeviceStandard = function(){
                   
                     console.log($scope.items);
                     base.post("zk_value/saveDeviceStandard",{data:angular.toJson($scope.items),ZK_REAGENT_PK:$scope.ph.PK,BATCH_NUMBER:$scope.ph.BATCH_NUMBER,device:$scope.device}).get(function(data){
                         if(data=='true'){
                             steveAl("保存成功",1000);
                         }
                     })
                } 

                $scope.getDeviceType();




            });





    function autoHeight() {
        var bHeight = $(window).height();
        var bWidth = $(window).width();

        $(".main").height(bHeight - $(".head-width").height() - 75);
        $(".add-zk-object").height(bHeight - $(".head-width").height() - 175);


    }
    autoHeight();


    $(window).resize(function () {
        autoHeight();
    });
</script>
